package org.mca.mcaweb.bean;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.faces.bean.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;

import org.mca.mcaweb.dao.DAO;
import org.mca.mcaweb.entity.Clieforn;


@Named
@ViewScoped
public class CliefornBean implements Serializable {

	private static final long serialVersionUID = 2810930627057811568L;

	private Clieforn clieforn = new Clieforn();

	private List<Clieforn> clieforns = new ArrayList<Clieforn>(0);
	
	private List<Clieforn> listClieforn;

	private String filtro;
	
	private boolean consultar = false;
	
	@Inject
	private DAO<Clieforn> dao;


	public void loadd() {
		this.setConsultar(true);
	}
	
	@PostConstruct
	public void init() {
		Date hms = new Date();
		System.out.println("Inicio: " + hms.getHours() + ":" + hms.getMinutes() + ":" + hms.getSeconds() + "-" +  Calendar.MILLISECOND);
		listClieforn = dao.listAll();
		//	listClieforn = dao.genericList("eq", "registerUser", loggedUser.getUser(), null, null, null);
		clieforns.addAll(listClieforn);
		System.out.println("Fim: " + hms.getHours() + ":" + hms.getMinutes() + ":" + hms.getSeconds() + "-" +  Calendar.MILLISECOND);
	}
	
	
	public void clear() {
		this.clieforn = new Clieforn();
	}
	
	public void edit(Clieforn clieforn) {
		this.setClieforn(dao.findById(new Long(clieforn.getClieforncodigo())));
	}

	public Clieforn getClieforn() {
		return clieforn;
	}

	public void setClieforn(Clieforn clieforn) {
		this.clieforn = clieforn;
	}

	public List<Clieforn> getClieforns() {
		return clieforns;
	}

	public void setClieforns(List<Clieforn> clieforns) {
		this.clieforns = clieforns;
	}

	public String getFiltro() {
		return filtro;
	}

	public void setFiltro(String filtro) {
		this.filtro = filtro;
	}

	public List<Clieforn> getListClieforn() {
		return listClieforn;
	}

	public void setListClieforn(List<Clieforn> listClieforn) {
		this.listClieforn = listClieforn;
	}

	public boolean isConsultar() {
		return consultar;
	}

	public void setConsultar(boolean consultar) {
		this.consultar = consultar;
	}
}